//子类继承父类后可以对父类的方法进行重写

//父类
class Cat{
    name: string;
    constructor(name: string) {
        this.name = name;
    }
    eat(food: string):string{
        let res = this.name + '爱吃' + food;
        console.log(res);
        return res;
    }
}

//子类
class Bosimao extends Cat {
    //子类对父类进行重写
    eat(food: string): string {
        let res = this.name + '爱吃' + food + '-子类重写后';
        console.log(res);
        return res;
    }
}

//子类继承父类 参数需要按父类的参数传参
let sanyue = new Bosimao('三月');

//执行父类的方法 eat
sanyue.eat('鸡胸肉');


